mfc 绘图美国队长盾牌
//美国队长的盾牌
CPen p1Pane(PS_SOLID,1,RGB(255,0,0));//创建画表盘的笔
CBrush b1Pane(RGB(225,0,0));//创建画表盘的刷子CBrush b1Pane(RGB(225,0,0));
//使用笔和刷子
pDC->SelectObject(&p1Pane);
pDC->SelectObject(&b1Pane);
CRect rect;
GetClientRect(&rect);//获取客户端的矩形窗口
int w = rect.Width()/2;
int h = rect.Height()/2;
CPoint center(w,h); //定义圆心
int R = w<h?w:h;//定义半径
int x = center.x;//得到圆心横纵坐标的数值
int y = center.y;
// 开始绘图
pDC->Ellipse(x-R,y-R,x R,y R);//画外圈
CBrush b2Pane(RGB(255,255,255));//定义刷子
pDC->SelectObject(&b2Pane);//换白色刷子
pDC->Ellipse(x-(R-(R*3)/13),y-(R-(R*3)/13),x (R-(R*3)/13),y (R-(R*3)/13));//画里圈
pDC->SelectObject(&b1Pane);//换红色刷子
pDC->Ellipse(x-(R-2*(R*3)/13),y-(R-2*(R*3)/13),x (R-2*(R*3)/13),y (R-2*(R*3)/13));//画里圈
CBrush b3Pane(RGB(0,0,255));
pDC->SelectObject(&b3Pane);//换蓝色刷子
pDC->Ellipse(x-(R*4)/12,y-(R*4)/12,x (R*4)/12,y (R*4)/12);//画里圈
//CBrush b4Pane(RGB(0,0,0));//´´½¨»±íÅ̵ÄË¢×Ó
CBrush b4Pane(RGB(255,255,255));
pDC->SelectObject(&b4Pane);//换白色刷子
//mPoint.x = x int(hl*sin(hAngle*PI/180));
//mPoint.y = y - int(hl*cos(hAngle*PI/180));
const double PI = 3.1415926;
int sR = (R*4)/12; //small R
int ssR = sR/2; // small small R
pDC->BeginPath(); //建立路径,给五角星涂色
pDC->MoveTo(x, y-sR);//先算SR,再算SSR,不然会乱掉的
pDC->LineTo(x int(ssR*sin(36*PI/180)),y - int(ssR*cos(36*PI/180)));
pDC->LineTo(x int(sR*sin(72*PI/180)),y - int(sR*cos(72*PI/180)));
pDC->LineTo(x int(ssR*sin(108*PI/180)),y - int(ssR*cos(108*PI/180)));
pDC->LineTo(x int(sR*sin(144*PI/180)),y - int(sR*cos(144*PI/180)));
pDC->LineTo(x int(ssR*sin(180*PI/180)),y - int(ssR*cos(180*PI/180)));
pDC->LineTo(x int(sR*sin(216*PI/180)),y - int(sR*cos(216*PI/180)));
pDC->LineTo(x int(ssR*sin(252*PI/180)),y - int(ssR*cos(252*PI/180)));
pDC->LineTo(x int(sR*sin(288*PI/180)),y - int(sR*cos(288*PI/180)));
pDC->LineTo(x int(ssR*sin(324*PI/180)),y - int(ssR*cos(324*PI/180)));
pDC->LineTo(x, y-sR);//构成闭合回路啊大哥
pDC->EndPath();//路径结束
评论